const { watch, series } = require('gulp');
const { paths } = require('./utils');
const tasks = require('./index');
const { copyImages } = require('./copyImages');
const { copyFonts } = require('./copyFonts');
const { template, css, serveReload, js } = tasks;

const { dev } = paths;
const watchOptions = {
  delay: 500,
};
function watchFiles() {
  // 监听nunjucks
  watch(dev.template, watchOptions, series(template, css, serveReload));
  //  监听css
  watch(dev.css, watchOptions, series(css, serveReload));
  // 监听js
  watch(dev.js, watchOptions, series(js, serveReload));
  // 监听图片
  watch(dev.image, watchOptions, series(copyImages, serveReload));
  // 监听字体
  watch(dev.font, watchOptions, series(copyFonts, serveReload));
}

exports.watchFiles = watchFiles;
